home *** CD-ROM | disk | FTP | other *** search
- package java.net;
-
- import java.util.Iterator;
- import java.util.LinkedHashMap;
- import java.util.LinkedList;
- import sun.net.InetAddressCachePolicy;
-
- final class InetAddress$Cache {
- private LinkedHashMap cache;
- private InetAddress.Cache.Type type;
-
- public InetAddress$Cache(InetAddress.Cache.Type var1) {
- this.type = var1;
- this.cache = new LinkedHashMap();
- }
-
- private int getPolicy() {
- return this.type == java.net.InetAddress.Cache.Type.Positive ? InetAddressCachePolicy.get() : InetAddressCachePolicy.getNegative();
- }
-
- public InetAddress$Cache put(String var1, Object var2) {
- int var3 = this.getPolicy();
- if (var3 == 0) {
- return this;
- } else {
- if (var3 != -1) {
- LinkedList var4 = new LinkedList();
- Iterator var5 = this.cache.keySet().iterator();
- long var6 = System.currentTimeMillis();
-
- while(var5.hasNext()) {
- String var8 = (String)var5.next();
- InetAddress.CacheEntry var9 = (InetAddress.CacheEntry)this.cache.get(var8);
- if (var9.expiration < 0L || var9.expiration >= var6) {
- break;
- }
-
- var4.add(var8);
- }
-
- var5 = var4.iterator();
-
- while(var5.hasNext()) {
- this.cache.remove(var5.next());
- }
- }
-
- long var10;
- if (var3 == -1) {
- var10 = -1L;
- } else {
- var10 = System.currentTimeMillis() + (long)(var3 * 1000);
- }
-
- InetAddress.CacheEntry var12 = new InetAddress.CacheEntry(var2, var10);
- this.cache.put(var1, var12);
- return this;
- }
- }
-
- public InetAddress.CacheEntry get(String var1) {
- int var2 = this.getPolicy();
- if (var2 == 0) {
- return null;
- } else {
- InetAddress.CacheEntry var3 = (InetAddress.CacheEntry)this.cache.get(var1);
- if (var3 != null && var2 != -1 && var3.expiration >= 0L && var3.expiration < System.currentTimeMillis()) {
- this.cache.remove(var1);
- var3 = null;
- }
-
- return var3;
- }
- }
- }
-